﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Login
{
    
    public delegate void childclose();
    public partial class login : Form
    {
       
        public login()
        {
          
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void login_Load(object sender, EventArgs e)
        {

        

        }

        private void button1_Click(object sender, EventArgs e)
        {
          

           string sql = "  select count(*) from admin where admin='"+textBox1.Text +"' and psw ='"+textBox2.Text +"' ";
            SqlCommand cmd = new SqlCommand(sql, new dataCon().conn);
            int n = Convert.ToInt32(cmd.ExecuteScalar());
            if (n != 0)
            {
                this.Hide();
                MainForm mainform = new MainForm();
                mainform.closefather += new childclose(this.Close);
                mainform.Show();
            }
            else
            {
                MessageBox.Show("管理员用户名密码错误");
                textBox1.Clear();
                textBox2.Clear();
            }
        }

        private void login_FormClosed(object sender, FormClosedEventArgs e)
        {
         
        }
    }
}